# Contributor: omni <omni+alpine@hack.org>
# Maintainer: omni <omni+alpine@hack.org>
pkgname=racksdb
pkgver=0.4.0
pkgrel=0
pkgdesc="YAML-based database of datacenter infrastructures"
url="https://rackslab.io/en/solutions/racksdb/"
arch="noarch"
license="GPL-3.0-or-later"
depends="clustershell py3-cairo pango py3-gobject3"
makedepends="asciidoctor py3-gpep517 py3-setuptools py3-wheel"
checkdepends="py3-pytest"
subpackages="$pkgname-doc $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/rackslab/RacksDB/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/RacksDB-$pkgver"

build() {
	gpep517 build-wheel --wheel-dir .dist --output-fd 3 3>&1 >&2

	for adocman in docs/man/*.adoc; do
		asciidoctor --backend manpage --attribute mansource='RacksDB 0.4.0' "$adocman"
	done
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl

	install -Dm644 docs/man/*.1 -t "$pkgdir"/usr/share/man/man1/
	install -Dm644 CHANGELOG.md -t "$pkgdir"/usr/share/doc/"$pkgname"/
	mv examples "$pkgdir"/usr/share/doc/"$pkgname"/
}

sha512sums="
365980fb69415ee5fab6eaf37ba296fad7481605bba3ac0ac28108ccf13f129b7ed7415cf8680b9b0c1a2e2bdb26448525fe5e338522f59a0cc7d4468590375e  racksdb-0.4.0.tar.gz
"
